<template>
  <div class="icon-header">
    <i v-if="isfold" class="el-icon-s-fold fold-menu" @click="isFold"></i>
    <i v-else class="el-icon-s-unfold fold-menu" @click="isFold"></i>
    <div class="content">
      <div class="content1">
        <el-breadcrumb separator="/">
          <template v-for="(item, index) in breadcrumb" :key="index">
            <el-breadcrumb-item>{{ item.name }}</el-breadcrumb-item>
          </template>
        </el-breadcrumb>
      </div>
      <div><user-login /></div>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref, computed } from 'vue'
import userLogin from './user-login.vue'
import { pathMapBreadcrumb } from '../../../utils/map-menus'
import { useStore } from '../../../store/store'
import { useRoute } from 'vue-router'
export default defineComponent({
  components: {
    userLogin
  },

  emits: ['foldChange'],
  setup(props, { emit }) {
    const store = useStore()
    const route = useRoute()
    const isfold = ref(true)
    const isFold = () => {
      isfold.value = !isfold.value
      emit('foldChange', !isfold.value)
    }
    const breadcrumb = computed(() =>
      pathMapBreadcrumb(store.state.login.userMenus, route.path)
    )
    return {
      isfold,
      isFold,
      breadcrumb
    }
  }
})
</script>

<style scoped lang="less">
.icon-header {
  display: flex;
  .fold-menu {
    font-size: 30px;
    cursor: pointer;
    margin-top: 5px;
  }
}
.content {
  flex: 1;
  height: 100%;
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 5px 20px;
}
.content1 {
  padding: 10px 0 0 0;
}
</style>
